package simulation;

/**
 * Created by fengliejv on 2022/4/12.
 */
public class NumberOfLinesToWriteString806 {
    public int[] numberOfLines(int[] widths, String s) {
        int[] result = new int[2];
        int lineCount = 1;
        int curCount = 0;
        for (int i = 0; i < s.length(); i++) {
            int width = widths[s.charAt(i)-'a'];
            if(curCount+width>100){
                lineCount++;
                curCount=0;
            }
            curCount+=width;
        }
        result[0]=lineCount;
        result[1]=curCount;
        return result;
    }
}
